@page "/role"
@inject DialogService DialogService
@using BootBlazorApp1.Model
<AdminTable TItem="Role" 
            ShowExtendEditButtonCallback="@(role =>role.RoleName!="管理员")"
            ShowExtendDeleteButtonCallback="@(role=>role.RoleName!="管理员")">
    <TableColumns>
        <TableColumn @bind-Field="context.RoleName"></TableColumn>
    </TableColumns>
    <BeforeRowButtonTemplate Context="value"> 
        <TableCellButton Text="编辑菜单" OnClick="()=>ShowEditMenuDialog(value.Id)" ></TableCellButton>
    </BeforeRowButtonTemplate>
</AdminTable>

@code {

    private void ShowEditMenuDialog(int roleId)
    {
        DialogService.ShowModal<EditMenuDialog>(new ResultDialogOption()
        {
            // 普通的需要这么建立
            // Component = BootstrapDynamicComponent.CreateComponent<EditMenuDialog>(new Dictionary<string, object?>()
            // {
            //     [nameof(EditMenuDialog.RoleId)]=roleId
            // })
            // Modal需要这么传参
            ComponentParameters = new Dictionary<string, object>()
            {
                [nameof(EditMenuDialog.RoleId)]=roleId
            }
        });
    }

}